﻿using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace ProjectManage.Core.Entity
{
    /// <summary>
    /// 自定义实体基类 Guid主键
    /// </summary>
    public abstract class DBEntityBase : EntityBase<Guid, MasterDbContextLocator>
    {
        public DBEntityBase()
        {
            Id = Guid.NewGuid();
        }
    }

    public abstract class DBEntityBase<TKey, TDbContextLocator1> : PrivateCommonEntity<TKey>
        where TDbContextLocator1 : class, IDbContextLocator
    {
    }


    public abstract class PrivateCommonEntity<TKey> : IPrivateEntity
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Comment("Id主键")]
        public virtual TKey? Id { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Comment("创建时间")]
        public virtual DateTime? CreatedTime { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        [Comment("更新时间")]
        public virtual DateTime? ModifiedTime { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [Comment("创建人")]
        [MaxLength(50)]
        public virtual string Creater { get; set; }

        /// <summary>
        /// 创建者名称
        /// </summary>
        [Comment("创建者名称")]
        [MaxLength(100)]
        public virtual string CreatedName { get; set; }

        /// <summary>
        /// 修改人
        /// </summary>
        [Comment("修改人")]
        [MaxLength(50)]
        public virtual string Modifier { get; set; }

        /// <summary>
        /// 修改者名称
        /// </summary>
        [Comment("修改者名称")]
        [MaxLength(100)]
        public virtual string ModifiedName { get; set; }

    }
}